#!/bin/bash

#获取root权限密码
isNeedCheck=1
passwdCheck=0
passwd=""
if [ -n "$1" ]; then
    passwd="$1"
else
    echo -n "请输入root用户密码: "
    read passwd
fi

#验证密码正确性
until [ $passwdCheck = 1 ];do
    echo $passwd | sudo -S ls 1>/dev/null 2>/dev/null
    res=$?
    if [ $res -eq 0 ];then
        passwdCheck=1
        break
    fi
    passwd=""
    echo -n "密码错误，请重新输入root用户密码: "
    read passwd
done
